<template>
    <el-container>
        <el-header>
            <div>
                <img src="../assets/logo.png" alt="">
                <span>扶贫助农平台</span>
            </div>
            <el-menu :default-active="$route.path" mode="horizontal"
             background-color="#3f3e3d" text-color="#fff" active-text-color="#fff" router>
               <el-menu-item v-for="(item,i) in navList" :key="i" :index="item.path">
                   <template slot="title">
                       <span>{{item.title}}</span>
                   </template>
               </el-menu-item>
            </el-menu>
        </el-header>
        <el-main>
            <router-view/>
        </el-main>
    </el-container>
</template>

<script>
export default{
    data(){
        return{
            navList:[
                {path:'/index',title:'首页'},
                {path:'/alleviationView',title:'扶贫政策'},
                {path:'/poorView',title:'贫困户'},
                {path:'/msgboardView',title:'留言板'},
                {path:'/userView',title:'用户'},
                {path:'/volunteerView',title:'志愿者'}, 
                {path:'/collectionView',title:'收藏'}, 
                {path:'/carouselView',title:'轮播图'},
                {path:'/main',title:'后台管理'},
                
            ],
            //"indexPath":"/index"
        }
    },
    // methods:{
    //     watch: {
    //     "$route.path": function () {
    //       window.console.log("watch触发");
    //       this.indexPath = "/" + this.$route.path.split("/")[1];
    //     },
    //   },
    // },
    // created() {
    //   this.indexPath = "/" + this.$route.path.split("/")[1];
    // },
}
</script>

<style scoped lang="scss">
.el-header{
    display: flex;
    justify-content: space-between;
    background-color: #3f3e3d;
    div{
        img{
            width: 50px;
            pad: 5px;
        }
        display: flex;
        align-items: center;
        font-size: 30px;
        color: white;
    }
}
</style>